package com.morgankelly.service;

import java.util.List;

import com.morgankelly.dao.BlogCommentDAO;
import com.morgankelly.dao.BlogDAO;
import com.morgankelly.dao.CategoryDAO;
import com.morgankelly.dao.TagDAO;
import com.morgankelly.po.Blog;
import com.morgankelly.po.BlogComment;
import com.morgankelly.po.Category;
import com.morgankelly.po.Tag;

public class BlogServiceImpl implements BlogService {
	
	public CategoryDAO categoryDAO = CategoryDAO.get();
	public BlogDAO blogDAO = BlogDAO.get();
	public BlogCommentDAO blogCommentDAO = BlogCommentDAO.get();
	public TagDAO tagDAO = TagDAO.get();

	@Override
	public List<Category> getCategoryList() {
		return categoryDAO.findAll();
	}
	@Override
	public List<Blog> getBlogList() {
		return blogDAO.findAll();
	}
	@Override
	public List<BlogComment> getBlogCommentList() {
		return blogCommentDAO.findAll();
	}
	@Override
	public List<Tag> getTagList() {
		return tagDAO.findAll();
	}
	
	
	@Override
	public void addCategory(Category category) {
	    categoryDAO.add(category);
	}
	@Override
	public void addBlog(Blog blog) {
		blogDAO.add(blog);
	}
	@Override
	public void addBlogComment(BlogComment blogComment) {
		blogCommentDAO.add(blogComment);
	}
	@Override
	public void addTag(Tag tag) {
		tagDAO.add(tag);
	}
	
	
	@Override
	public Category getCategoryByID(Long id) {
		return categoryDAO.findByID(id);
	}
	@Override
	public Blog getBlogByID(Long id) {
		return blogDAO.findByID(id);
	}
	@Override
	public BlogComment getBlogCommentByID(Long id) {
		return blogCommentDAO.findByID(id);
	}
	@Override
	public Tag getTagByID(Long id) {
		return tagDAO.findByID(id);
	}
	
	
	@Override
	public void deleteCategoryByID(Long id) {
		categoryDAO.deleteByID(id);
	}
	@Override
	public void deleteBlogByID(Long id) {
		blogDAO.deleteByID(id);
	}
	@Override
	public void deleteBlogCommentByID(Long id) {
		blogCommentDAO.deleteByID(id);
	}
	@Override
	public void deleteTagByID(Long id) {
		tagDAO.deleteByID(id);
	}
	
	@Override
	public int getBlogNumByCategoryID(Long id) {
		return blogDAO.getBlogNumByCategoryID(id);
	}
	@Override
	public List<Blog> getBlogListBySearchKey(String searchKey) {
		return blogDAO.getBlogListBySearchKey(searchKey);
	}
	@Override
	public int getCommentNumByBlogID(Long id) {
		return blogCommentDAO.getCommentNumByBlogID(id);
	}
	@Override
	public void updateCategory(Long id, String name, String description) {
		categoryDAO.update(id, name, description);
	}
	@Override
	public void updateBlog(Long id, String title, String content, Long accountID, Long categoryID) {
		blogDAO.update(id, title, content, accountID, categoryID);
	}
	@Override
	public void updateBlogComment(Long id) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void updateTag(Long id, String name) {
		tagDAO.update(id, name);
	}
	
	
}
